<?php

namespace Jb\Utils\Comparison\Strategy;

use Jb\Object,
    Jb\Utils\Comparison\Comparator,
    Jb\Utils\Comparison\Comparable;

class Regex extends Object implements Comparable {

    private $sPattern;

    public function __construct($regexPattern = null) {
        $this->setPattern($regexPattern);
    }

    public function setPattern($regexPattern) {
        $this->sPattern = (string) $regexPattern;
    }

    public function compareTo(Object $comparableObject) {
        if(preg_match($this->sPattern, $comparableObject->toString())) {
            return true;
        } else {
            return false;
        }
    }

    public function toString() {
        return $this->sPattern;
    }

}

?>
